@echo off
echo ========================================
echo API端点功能测试
echo ========================================

echo 等待服务启动...
timeout /t 10 /nobreak >nul

echo.
echo ========================================
echo 1. 用户管理API测试
echo ========================================

echo 测试用户注册...
curl -X POST http://localhost:8080/api/users/register ^
  -H "Content-Type: application/json" ^
  -d "{\"username\":\"testuser\",\"email\":\"test@example.com\",\"password\":\"password123\"}" ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo 测试用户登录...
curl -X POST http://localhost:8080/api/users/login ^
  -H "Content-Type: application/json" ^
  -d "{\"username\":\"testuser\",\"password\":\"password123\"}" ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo ========================================
echo 2. 课程管理API测试
echo ========================================

echo 测试创建课程...
curl -X POST http://localhost:8080/api/courses ^
  -H "Content-Type: application/json" ^
  -d "{\"title\":\"测试课程\",\"description\":\"这是一个测试课程\",\"instructor\":\"测试讲师\"}" ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo 测试获取课程列表...
curl -X GET http://localhost:8080/api/courses ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo ========================================
echo 3. 练习管理API测试
echo ========================================

echo 测试创建练习...
curl -X POST http://localhost:8080/api/exercises ^
  -H "Content-Type: application/json" ^
  -d "{\"title\":\"测试练习\",\"description\":\"这是一个测试练习\",\"courseId\":1}" ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo 测试获取练习列表...
curl -X GET http://localhost:8080/api/exercises ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo ========================================
echo 4. 学习进度API测试
echo ========================================

echo 测试创建学习进度...
curl -X POST http://localhost:8080/api/progress ^
  -H "Content-Type: application/json" ^
  -d "{\"userId\":1,\"courseId\":1,\"progress\":50}" ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo 测试获取学习进度...
curl -X GET http://localhost:8080/api/progress/1 ^
  -w "\nHTTP状态码: %%{http_code}\n"

echo.
echo ========================================
echo API测试完成！
echo ========================================

echo 📋 测试结果说明:
echo - HTTP状态码 200: 成功
echo - HTTP状态码 400: 请求错误
echo - HTTP状态码 404: 资源不存在
echo - HTTP状态码 500: 服务器错误
echo.

echo 🔍 查看详细日志:
echo docker-compose logs -f api-gateway
echo docker-compose logs -f user-management-service
echo docker-compose logs -f course-management-service
echo.

pause
